<?php

namespace App\Entities;

class QrcodeAdvertisingEntity extends ABaseEntity
{
    /**
     * QrcodeAdvertisingEntity constructor.
     * @param QrcodeAdvertisingModel $model
     */
    public function __construct(QrcodeAdvertisingModel $model)
    {
        $this->model = $model;
    }

    /**
     * @param int $userId
     * @return QrcodeAdvertisingEntity|null
     */
    public static function findByUserId(int $userId)
    {
        $model = QrcodeAdvertisingModel::where('uid', $userId)
            ->first();

        if (is_null($model)) {
            return null;
        }
        return new self($model);
    }

    /**
     * @param int $agentid
     */
    public function setAgentid(int $agentid): void
    {
        $this->model->agentid = $agentid;
    }

    /**
     * @return int
     */
    public function getAgentid(): int
    {
        return (int)$this->model->agentid;
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return (int)$this->model->id;
    }

    /**
     * @param int $id
     */
    public function setId(int $id): void
    {
        $this->model->id = $id;
    }

    /**
     * @return int
     */
    public function getUid(): int
    {
        return (int)$this->model->uid;
    }

    /**
     * @param int $uid
     */
    public function setUid(int $uid): void
    {
        $this->model->uid = $uid;
    }

    /**
     * @return int
     */
    public function getCleanid(): int
    {
        return (int)$this->model->cleanid;
    }

    /**
     * @param int $cleanid
     */
    public function setCleanid(int $cleanid): void
    {
        $this->model->cleanid = $cleanid;
    }

    /**
     * @return int
     */
    public function getCreateAt(): int
    {
        return (int)$this->model->create_at;
    }

    /**
     * @param int $create_at
     */
    public function setCreateAt(int $create_at): void
    {
        $this->model->create_at = $create_at;
    }

    /**
     * @return int
     */
    public function getUpdateAt(): int
    {
        return (int)$this->model->update_at;
    }

    /**
     * @param int $update_at
     */
    public function setUpdateAt(int $update_at): void
    {
        $this->model->update_at = $update_at;
    }
}
